vim.keymap.set("v", "p", "pgvy", { desc = "Paste", noremap = true, silent = true })
vim.keymap.set("v", "P", "Pgvy", { desc = "Paste", noremap = true, silent = true })

-- vim.keymap.set({ "n", "i", "v", "t" }, "<Left>", "<Nop>", { noremap = true, silent = true })
-- vim.keymap.set({ "n", "i", "v", "t" }, "<Right>", "<Nop>", { noremap = true, silent = true })
-- vim.keymap.set({ "n", "i", "v", "t" }, "<Up>", "<Nop>", { noremap = true, silent = true })
-- vim.keymap.set({ "n", "i", "v", "t" }, "<Down>", "<Nop>", { noremap = true, silent = true })
-- vim.keymap.set({ "n", "i", "v", "t" }, "<BS>", "<Nop>", { noremap = true, silent = true })

vim.keymap.set("n", "gt", ":bnext<CR>", { desc = "Next Buffer", noremap = true, silent = true })
vim.keymap.set("n", "gT", ":bprevious<CR>", { desc = "Prev Buffer", noremap = true, silent = true })
vim.keymap.set("n", "<leader>bn", ":bnext<CR>", { desc = "Next Buffer", noremap = true, silent = true })
vim.keymap.set("n", "<leader>bf", ":bprevious<CR>", { desc = "Prev Buffer", noremap = true, silent = true })

vim.keymap.set("n", "<A-k>", "<cmd>m .-2<cr>==", { desc = "Move up", noremap = true, silent = true })
vim.keymap.set("n", "<A-j>", "<cmd>m .+1<cr>==", { desc = "Move down", noremap = true, silent = true })
vim.keymap.set("i", "<A-k>", "<esc><cmd>m .-2<cr>==gi", { desc = "Move up", noremap = true, silent = true })
vim.keymap.set("i", "<A-j>", "<esc><cmd>m .+1<cr>==gi", { desc = "Move down", noremap = true, silent = true })
vim.keymap.set("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move up", noremap = true, silent = true })
vim.keymap.set("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move down", noremap = true, silent = true })

vim.keymap.set({ "n", "i", "v", "t" }, "<C-`>", "<CMD>ToggleTerm size=10 direction=horizontal<cr>")

vim.keymap.set(
  "n",
  "<leader>uT",
  function() vim.fn.setreg("+", vim.trim(vim.fn.getreg "+")) end,
  { desc = "Trim Register +", noremap = true, silent = true }
)
vim.keymap.set(
  "n",
  "<leader>u%",
  function() vim.fn.setreg("+", vim.fn.expand "%:t:r") end,
  { desc = "File Name To Register +", noremap = true, silent = true }
)

-- vim.keymap.set("c", "<C-a>", "<Home>", { noremap = true, silent = true })
-- why not use?
vim.cmd [[cnoremap <C-a> <Home>]]
vim.cmd [[cnoremap <C-e> <End>]]
vim.cmd [[cnoremap <C-f> <Right>]]
vim.cmd [[cnoremap <C-b> <Left>]]
vim.cmd [[cmap <C-k> <C-p>]]
vim.cmd [[cmap <C-j> <C-n>]]
-- vim.cmd [[cmap <Up> <C-k>]]
-- vim.cmd [[cmap <Down> <C-j>]]
vim.cmd [[cnoremap <C-o> <C-f>]]
vim.cmd [[cnoremap <C-d> <Del>]]

vim.cmd [[inoremap <C-a> <Home>]]
vim.cmd [[inoremap <C-e> <End>]]
vim.cmd [[inoremap <C-f> <Right>]]
vim.cmd [[inoremap <C-b> <Left>]]

-- karabiner
vim.cmd [[imap <Up> <C-k>]]
vim.cmd [[imap <Down> <C-j>]]

vim.cmd [[imap <C-k> <C-p>]]
vim.cmd [[imap <C-j> <C-n>]]
vim.cmd [[inoremap <C-d> <Del>]]
